#include "ThresholdSameRegion.hpp"

ThresholdSameRegion::ThresholdSameRegion(const girl::tools::Image &image, int threshold)
    : _image(image),
    _threshold(threshold)
{}


bool ThresholdSameRegion::same(const girl::point &p, girl::direction dir)
{
    girl::point p2 = p;
    p2.move(dir);

    return (_image.getPixel(p.x(),p.y()).a() <= _threshold && _image.getPixel(p2.x(),p2.y()).a() <= _threshold)
            || (_image.getPixel(p.x(),p.y()).a() > _threshold && _image.getPixel(p2.x(),p2.y()).a() > _threshold);
}
